﻿<template>
    <div class="container" style="width:99%;margin-top:-25px;">
        <!-- 查询条件 -->
        <div class="query-box">
            <el-form :model="queryBox" status-icon ref="queryBox">
                <div class="schoolBoxCont">
                    <!-- <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">三方名称</div>
                            <div class="schoolBoxContItemInput">
                                <el-input clearable v-model="queryBox.name" placeholder="三方名称"></el-input>
                            </div>
                        </el-form-item>
                    </div> -->
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">三方姓名</div>
                            <div class="schoolBoxContItemInput">
                                <el-input clearable v-model="queryBox.contact" placeholder="三方姓名"></el-input>
                            </div>
                            <!-- <div class="schoolBoxContItemInput">
                                <el-select
                                    filterable
                                    v-model="queryBox.contact"
                                    clearable
                                    placeholder="请选择"
                                >
                                    <el-option
                                        v-for="item in schoolTripartiteTypeOption"
                                        :key="item.key"
                                        :label="item.value"
                                        :value="item.value"
                                    ></el-option>
                                </el-select> 
                            </div>-->
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">联系人</div>
                            <div class="schoolBoxContItemInput">
                                <el-input clearable v-model="queryBox.name" placeholder="联系人"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">手机号</div>
                            <div class="schoolBoxContItemInput">
                                <el-input clearable v-model="queryBox.phone" placeholder="手机号"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">意向程度</div>
                            <div class="schoolBoxContItemInput">
                                <el-select clearable filterable v-model="queryBox.tripartiteType">
                                    <el-option
                                        v-for="item in tripartiteTypeOption"
                                        :key="item.key"
                                        :label="item.value"
                                        :value="item.key"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">所在地区：</div>
                            <div class="schoolBoxContItemInput" style="width:300px">
                                <el-cascader
                                    clearable
                                    style="width:100% !important"
                                    size="large"
                                    :options="options"
                                    v-model="selectedOptions"
                                ></el-cascader>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">大区经理</div>
                            <div class="schoolBoxContItemInput">
                                <el-select
                                    v-model="queryBox.userId"
                                    filterable
                                    placeholder="请选择"
                                    value-key="id"
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item in userName"
                                        :key="item.id"
                                        :label="item.realName"
                                        :value="item.id"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle" style="width:115px">创建时间</div>
                            <div class="schoolBoxContItemInput" style="width:428px">
                                <el-date-picker
                                    v-model="createrDateArry"
                                    type="daterange"
                                    range-separator="至"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                    :default-time="['00:00:00', '23:59:59']"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    format="yyyy-MM-dd HH:mm:ss"
                                ></el-date-picker>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">所属部门</div>
                            <div class="schoolBoxContItemInput">
                                <el-select
                                    v-model="queryBox.threeDepartmentId"
                                    clearable
                                    filterable
                                >
                                    <el-option
                                        v-for="item in threeDept"
                                        :key="item.id"
                                        :label="item.deptName"
                                        :value="item.id"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                </div>
            </el-form>
            <div class="from-btns">
                <kt-button
                    :label="$t('action.reset')"
                    perms="true"
                    type="primary"
                    @click="reset('queryBox')"
                />
                <kt-button
                    :label="$t('action.search')"
                    perms="true"
                    type="primary"
                    @click="get_subcentersearch"
                />
            </div>
        </div>
        <!-- 批量删除按钮 -->
        <div class="add-btns fl">
            <kt-button
                label="批量删除"
                :perms="btnBatchDelete"
                :size="size"
                type="danger"
                @click="handleBatchDelete"
                :disabled="this.selections.length === 0"
                style="float:left;"
            />
            <kt-button
                :label="$t('导出')"
                :perms="btnExport"
                type="primary"
                @click="handleExport"
                style="float:left;"
            />
        </div>
        <!-- <div class="fr" style="margin-bottom:20px">
            <kt-button
                label="新增三方"
                type="primary"
                perms="directCampCenter:myschool:add"
                @click="handleNewADD"
            ></kt-button>
        </div>-->
        <!--表格内容栏-->
        <div class="btn">
            <Crm-table
                @selectionChange="selectionChange"
                class="table-width"
                MyThree
                width="400"
                :permsEdit="tableBtnEdit"
                :permsSee="tableBtnSee"
                :permsDelete="tableBtnDelete"
                :permsReport="tableBtnFollow"
                :data="pageResult"
                :columns="columns"
                :loading="loading"
                @findPage="findPage"
                @handleEdit="handleEdit"
                @handleReport="handleReport"
                @handleSee="handleSee"
                @handleDeleteDic="handleDelete"
            ></Crm-table>
        </div>
        <!--导入-->
        <el-dialog
            :title="'批量导入'"
            width="30%"
            :visible.sync="uploadOem"
            :close-on-click-modal="false"
        >
            <el-form :model="form">
                <el-form-item>
                    <el-upload
                        ref="uploadExcel"
                        :action="uploadUrl"
                        :limit="limitNum"
                        :auto-upload="false"
                        accept=".xls"
                        :before-upload="beforeUploadFile"
                        :on-change="fileChange"
                        :on-exceed="exceedFile"
                        :on-success="handleSuccess"
                        :on-error="handleError"
                        :file-list="fileList"
                        :on-remove="handleRemove"
                    >
                        <el-button size="small" plain>选择文件上传</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传xls(Excel97-2004)文件</div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button :size="size" @click.native="uploadOem = false">
                    {{
                    $t("action.cancel")
                    }}
                </el-button>
                <el-button :size="size" type="primary" @click.native="uploadFile">
                    {{
                    $t("立即上传")
                    }}
                </el-button>
            </div>
        </el-dialog>
        <!-- 跟进 -->
        <el-dialog
            :title="recordData.name"
            width="70%"
            :visible.sync="reportShow"
            :close-on-click-modal="false"
            @close="recordDataPopClose"
            class="MyThreePop"
        >
            <el-row>
                <el-col :span="12">
                    <el-col :span="6">
                        <p>沟通时间：</p>
                    </el-col>
                    <el-col :span="18">
                        <el-date-picker
                            style="width:100%"
                            v-model="recordData.communicationDate"
                            type="datetime"
                            placeholder="选择日期时间"
                            :default-time="mytime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            format="yyyy-MM-dd HH:mm:ss"
                            :picker-options="pickerOptions"
                        ></el-date-picker>
                    </el-col>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-col :span="3">
                        <p>沟通内容：</p>
                    </el-col>
                    <el-col :span="21">
                        <el-input
                            style="width:100%"
                            type="textarea"
                            :rows="2"
                            placeholder="请输入内容"
                            v-model="recordData.communicationContent"
                        ></el-input>
                    </el-col>
                </el-col>
            </el-row>
            <el-row style="margin-top:10px">
                <el-col :span="12">
                    <el-col :span="6">
                        <p style="margin-top:5px">跟进人：</p>
                    </el-col>
                    <el-col :span="18" style="margin-top:10px;">
                        {{
                        trackingPeople
                        }}
                    </el-col>
                </el-col>
                <el-col :span="12">
                    <el-col :span="6">
                        <p>下次跟进日期：</p>
                    </el-col>
                    <el-col :span="18">
                        <el-date-picker
                            style="width:100%"
                            v-model="recordData.nextTrackingDate"
                            type="datetime"
                            placeholder="选择日期时间"
                            :default-time="mytime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            format="yyyy-MM-dd HH:mm:ss"
                            :picker-options="pickerOptions"
                        ></el-date-picker>
                    </el-col>
                </el-col>
            </el-row>
            <kt-button
                class="stu-btn"
                :label="$t('action.save')"
                perms="true"
                size="medium"
                type="primary"
                @click="handleSaveRecord()"
            />
            <p class="tracking-tit">跟进情况</p>
            <Crm-table
                :showBatchDelete="showBatchDelete"
                class="tracking-table"
                :data="detailRecordInfoData"
                :columns="columns3"
                @findPage="findPage3"
                :loading="loading"
            ></Crm-table>
        </el-dialog>
    </div>
</template>
<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import KtButton from "@/views/Core/KtButton";
import StTable from "@/views/Core/StTable";
import CrmTable from "@/views/Core/CrmTable";
import CrmSwitch from "@/views/Core/CrmSwitch";
import { CodeToText } from "element-china-area-data";
import { baseUrl } from "@/utils/global";
import { regionDataPlus } from "element-china-area-data";
import axios from "axios";
import Checkrepeat from "@/views/Core/Checkrepeat";
import Cookies from "js-cookie";
export default {
    name: "School",
    components: {
        PopupTreeInput,
        CrmTable,
        KtButton,
        CrmSwitch,
        Checkrepeat
    },
    data() {
        return {
            isShowFlag: 0, //0:初始化部门、人员不显示  1:部门显示 2：人员显示
            showBatchDelete: false,
            mytime: "",
            size: "mini",
            selectDisabled: false, //跟进弹窗客户进展状态
            typeDisabled: false,
            schoolSectionArr: [], //学段数组
            filters: {
                name: ""
            },
            uploadOem: false, //文件上传
            limitNum: 1, //上传最大个数
            form: {
                file: ""
            },
            isTodayTracking: "",
            fileList: [],
            uploadUrl: baseUrl + "/file/upload", //文件上传地址
            downloadTmplUrl: baseUrl + "/template/schoolImportTemplate.xlsx", //模板下载地址
            // 查询条件
            student_data_from_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            // 客户跟进数据
            stuqueryTrackingData: {
                content: []
            },
            // 报备数据
            detailRecordInfoData: {
                content: []
            },
            // 查询条件
            student_data_from_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_type_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_progress_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_data_from_type_options: [
                {
                    label: " ",
                    key: " "
                }
            ],

            isRecord_type_options: [
                {
                    key: "1",
                    value: "已报备"
                },
                {
                    key: "2",
                    value: "未报备"
                }
            ],
            isTodayTracking_options: [
                {
                    value: "是",
                    label: "1"
                }
            ],

            student_level_cache_options: [
                {
                    key: " ",
                    value: " "
                }
            ],
            createDateArr: [], // 创建时间数组
            trackingDateArr: [], //跟进时间数组
            student_communication_type: [],
            queryBox: {
                name: "",
                tripartiteType: "",
                contact: "",
                peopleNum: "",
                schoolSystem: "",
                type: "",
                duty: "",
                phone: "",
                thirdProportion: "",
                thirdName: "",
                thirdPhone: "",
                thirdContractSignedDate: "",
                thirdContractEndDate: "",
                paymentSituation: "",
                feastNum: "",
                mettingNum: "",
                visitNum: "",
                thirdLevelDepartment: "",
                isRecord: "",
                auditStatus: "",
                threeDepartmentId:''
            },
            columns: [
                { type: "index", label: "序号", minWidth: 50 },
                { prop: "contact", label: "三方姓名", minWidth: 100 },
                { prop: "name", label: "三方单位", minWidth: 180 },
                { prop: "phone", label: "手机号", minWidth: 80 },
                { prop: "regionaManager", label: "大区经理", minWidth: 80 },
                { prop: "thirdProportion", label: "分成比例", minWidth: 80 },
                { prop: "tripartiteTypeStr", label: "意向程度", minWidth: 80 },
                { prop: "diqu", label: "地区", minWidth: 190 },
                { prop: "threeDepartmentName", label: "所属部门", minWidth: 120 },
                { prop: "createrDate", label: "创建时间", minWidth: 190 }
                // {
                //   prop: "createDate",
                //   sortable: "true",
                //   label: "创建时间",
                //   minWidth: 140
                // }
            ],
            columns2: [
                { type: "index", label: "序号", minWidth: 10 },
                { prop: "trackingDate", label: "跟进时间", minWidth: 100 },
                { prop: "contactTrack", label: "联系人", minWidth: 50 },
                { prop: "typeTrack", label: "客户类型", minWidth: 80 },
                { prop: "progressTrack", label: "客户进展", minWidth: 50 },
                { prop: "communicationType", label: "沟通形式", minWidth: 50 },
                {
                    prop: "communicationContent",
                    label: "沟通内容",
                    minWidth: 120
                },
                {
                    prop: "nextTrackingDateDetail",
                    label: "下次跟进时间",
                    minWidth: 100
                }
            ],
            columns3: [
                { type: "index", label: "序号", minWidth: 10 },
                { prop: "communicationDate", label: "沟通时间", minWidth: 100 },
                {
                    prop: "communicationContent",
                    label: "沟通内容",
                    minWidth: 100
                },
                {
                    prop: "nextTrackingDate",
                    label: "下次跟进时间",
                    minWidth: 100
                }
            ],
            pageResult: {
                content: []
            },
            operation: false, // true:新增, false:编辑
            batchdistribution: false, //显示批量分配弹窗
            selectionsLength: "",
            selections: [], //选中列表集合
            ids: [], //分配ID集合
            deptData: [], //部门树
            deptTree: {
                label: "deptName",
                children: "children"
            },
            addFollow: false, //显示跟进窗口
            deptinputValue: "",
            // 划分方式
            deptmodeoptions: [
                {
                    label: "分配至部门",
                    value: "11"
                },
                {
                    label: "分配至个人",
                    value: "9"
                }
            ],

            deptuseroption: [], //部门用户
            addstuformData: {},
            deptmodeoptionsValue: "",

            AllotData: {
                assignType: 2,
                ids: "",
                thirdLevelDepartment: "",
                userId: "",
                belong_to_type: ""
            },
            // 地区
            options: regionDataPlus,
            selectedOptions: [],
            saveData: {
                type: "",
                dataFrom: "",
                progress: "",
                code: "",
                name: "",
                schoolSection: "",
                userId: "",
                thirdPatry: "",
                isLock: "",
                createrDateStart: "", //创建开始时间
                createrDateEnd: "", //创建结束时间
                trackingDateStart: "", //最新跟进开始时间
                trackingDateEnd: "", //最新跟进结束时间
                orderName: "",
                orderType: "",
                id: "",
                progress: "",
                belongToName: "",
                userId: Cookies.get("userId"),
                communicationType: ""
            },
            trackingPeople: Cookies.get("realName"),
            loading: false, // 加载标识
            // 限制跟进时间
            pickerOptions: {
                // disabledDate(time) {
                //     return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
                // }
            },
            pageRequest2: {
                pageNum: 1,
                pageSize: 10
            },
            checkrepeatShow: false,
            checkloading: false,
            checkMessage: "",
            isLoadingSuccess: false,
            reportShow: false,
            recordData: {
                trackingDate: "",
                expectedClosingDate: ""
            },
            queryTrackingRecordData: {},
            threeDept: [],
            school_recordType_options: [],
            userName: [],
            school_audit_status_option: [],
            auditStatus: "",
            tripartiteTypeOption: [],
            pageRequest3: {
                pageNum: 1,
                pageSize: 10
            },
            createrDateArry:[],
            dataType: this.$route.fullPath.indexOf('dataType=2')>-1?2:'', // 根据参数动态添加权限按钮
        };
    },
    beforeMount: function() {
        this.$api.dropdown.tripartiteType().then(res => {
            if (res.result == 2) {
                this.$message({ message: res.msg, type: "error" });
            } else {
                this.tripartiteTypeOption = res.keyValueList;
            }
        });
        let dataType=''
        if (this.$route.fullPath.indexOf("dataType=2") > -1) {
            dataType = 2;
        }
        this.$api.agent.myTripartiteList({dataType:dataType}).then(res => {
            if (res.result == 2) {
                this.$message({ message: res.msg, type: "error" });
            } else {
                this.schoolTripartiteTypeOption = res.data;
            }
        });
    },
    methods: {
        transformRouteBtnParam(){
            if(this.dataType&&this.dataType==2){
                this.btnBatchDelete='directCampCenter:tz:MyThreeManage:batchDelete'
                this.btnExport='directCampCenter:tz:MyThreeManage:export'
                this.tableBtnDelete='directCampCenter:tz:MyThreeManage:delete'
                this.tableBtnFollow='directCampCenter:tz:MyThreeManage:follow'
                this.tableBtnSee='directCampCenter:tz:MyThreeManage:see'
                this.tableBtnEdit='directCampCenter:tz:MyThreeManage:edit'
            }else{
                this.btnBatchDelete='directCampCenter:MyThreeManage:batchDelete'
                this.btnExport='directCampCenter:MyThreeManage:export'
                this.tableBtnDelete='directCampCenter:MyThreeManage:delete'
                this.tableBtnFollow='directCampCenter:MyThreeManage:follow'
                this.tableBtnSee='directCampCenter:MyThreeManage:see'
                this.tableBtnEdit='directCampCenter:MyThreeManage:edit'
            }
        },
        // 客户类型
        get_student_type() {
            this.student_type_options = JSON.parse(
                localStorage.getItem("schoolType")
            );
            this.school_audit_status_option = JSON.parse(
                localStorage.getItem("schoolAuditStatus")
            );
            var  deptType=''
            if (this.$route.fullPath.indexOf("dataType=2") > -1) {
                deptType = 5;
            }else{
                deptType = 4
            }
            this.$api.dropdown
                .users({ userType: 3, deptType: deptType, accountStatus: 1 })
                .then(res => {
                    if (res.result == 1) {
                        this.userName = res.userInfoList;
                    }
                });
            this.get_threeDept()
        },
        get_threeDept() {
            var  deptType=''
            if (this.$route.fullPath.indexOf("dataType=2") > -1) {
                deptType = 5;
            }else{
                deptType = 4
            }
            this.$api.user.queryDepartmentListtz({deptLevel: 3,deptType:deptType}).then(res => {
                this.threeDept = res.departmentInfoList;
            });
            this.$api.dropdown
                .users({ userType: 3, deptType: deptType, accountStatus: 1 })
                .then(res => {
                    if (res.result == 1) {
                        this.userName = res.userInfoList;
                    }
                });
        },
        // 客户来源
        get_student_data_from() {
            this.student_data_from_options = JSON.parse(
                localStorage.getItem("schoolSource")
            );
        },
        get_dataTime() {
            let dateTime = new Date();
            this.saveData.trackingDate = this.dateFormat(dateTime);
            let mytime = dateTime.toLocaleTimeString("chinese", {
                hour12: false
            }); //获取当前时间
            this.mytime = mytime;
        },
        // 获取方式
        get_student_data_from_type() {
            this.student_data_from_type_options = JSON.parse(
                localStorage.getItem("schoolDataFromType")
            );
        },

        // 客户进展
        get_student_progress() {
            this.student_progress_options = JSON.parse(
                localStorage.getItem("schoolProgress")
            );
        },

        student_progress_change(value) {
            this.queryBox.student_progressValue = value.toString();
        },

        // 学段
        get_level_cache() {
            this.student_level_cache_options = JSON.parse(
                localStorage.getItem("schoolSection")
            );
        },
        recordDataPopClose() {
            this.recordData = {};
        },

        // 获取分页数据
        findPage: function(data) {
            if (data !== null) {
                this.loading = true;
                this.pageRequest = data.pageRequest;
            }

            //如果创建时间查询的时候选择了，给查询参数赋值
            if (this.createrDateArry.length > 0) {
                this.queryBox.createrDateStart = this.createrDateArry[0];
                this.queryBox.createrDateEnd = this.createrDateArry[1];
            }

            //如果跟进时间查询的时候选择了，给查询参数赋值
            if (this.trackingDateArr.length > 0) {
                this.queryBox.trackingDateStart = this.trackingDateArr[0];
                this.queryBox.trackingDateEnd = this.trackingDateArr[1];
            }

            this.queryBox.pageNum = this.pageRequest.pageNum;
            this.queryBox.pageSize = this.pageRequest.pageSize;
            let dataType=''
            // 获取参数判断是否是商务拓展中心
            if(this.$route.fullPath.indexOf('dataType=2')>-1){
                dataType = 2;
            }
            if(dataType==2){
                this.queryBox.dataType=2
            }
            if (this.schoolSectionArr.length > 0) {
                this.queryBox.schoolSection = this.schoolSectionArr.join(",");
            } else if (this.schoolSectionArr.length == 0) {
                this.queryBox.schoolSection = "";
            }
            this.$api.agent
                .querySchoolTripartiteList(this.queryBox)
                .then(res => {
                    let content = { content: res.data, totalSize: res.total };
                    this.pageResult = content;
                    this.pageResult.content.forEach(item => {
                        item.thirdProportion
                            ? (item.thirdProportion =
                                item.thirdProportion + "%")
                            : "";
                        // 去掉时间的时分秒
                        item.thirdContractSignedDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.thirdContractSignedDate
                        );
                        item.thirdContractEndDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.thirdContractEndDate
                        );
                        item.createrDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.createrDate
                        );
                        //转换地区
                        if (
                            (item.province == null && item.city == null) ||
                            (item.province == "null" && item.city == "null")
                        ) {
                            item.diqu = "";
                        } else {
                            item.diqu =
                                CodeToText[item.province] +
                                CodeToText[item.city] +
                                CodeToText[item.area];
                        }
                        //转换y意向程度
                        this.tripartiteTypeOption.forEach(type_item => {
                            if (type_item.key == item.tripartiteType) {
                                item.tripartiteTypeStr = type_item.value;
                            }
                        });
                    });

                    this.loading = false;
                })
                .then(data != null ? data.callback : "");
        },

        // 搜索
        get_subcentersearch() {
            this.loading = true;
            this.queryBox.province = this.selectedOptions[0];
            this.queryBox.city = this.selectedOptions[1];
            this.queryBox.area = this.selectedOptions[2];
            this.pageRequest.pageNum = 1;
            this.findPage(null);
        },

        // 重置
        reset(queryBox) {
            // this.$refs.queryBox.resetFields();
            this.queryBox.name = "";
            this.queryBox.contact = "";
            this.queryBox.peopleNum = "";
            this.queryBox.schoolSystem = "";
            this.queryBox.type = "";
            this.queryBox.duty = "";
            this.queryBox.phone = "";
            this.queryBox.thirdProportion = 0;
            this.queryBox.tripartiteType = "";
            this.queryBox.thirdPhone = "";
            this.queryBox.thirdContractSignedDate = "";
            this.queryBox.thirdContractEndDate = "";
            this.queryBox.paymentSituation = "";
            this.queryBox.feastNum = "";
            this.queryBox.mettingNum = "";
            this.queryBox.visitNum = "";
            this.queryBox.selectedOptions = [];
            this.queryBox.province = "";
            this.queryBox.thirdLevelDepartment = "";
            this.queryBox.belongToName = "";
            this.selectedOptions = [];
            this.queryBox.city = "";
            this.queryBox.area = "";
            this.queryBox.isRecord = "";
            this.queryBox.auditStatus = "";
            this.pageRequest.pageNum = 1;
            this.queryBox.userId=''
            this.queryBox.threeDepartmentId=''
            this.createrDateArry=[]
            this.queryBox.createrDateStart=''
            this.queryBox.createrDateEnd =''
            this.findPage(null);
        },

        // 批量删除
        handleBatchDelete() {
            let schids = this.selections.map(item => item.id);
            this.$confirm(
                "确认删除这" + this.selections.length + "个吗？",
                "提示",
                {}
            ).then(() => {
                this.editLoading = true;
                this.$api.agent
                    .schoolTripartiteDeleteBatchIds({
                        ids: this.ids
                        // dateType: 4
                    })
                    .then(res => {
                        if (res.result == 1) {
                            this.$message({
                                message: res.msg,
                                type: "success"
                            });
                            this.findPage(null);
                        } else {
                            this.$message({ message: res.msg, type: "error" });
                        }
                    });
            });
        },
        // 删除
        handleDelete(params) {
            this.$confirm("确定删除？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                this.$api.agent
                    .deleteTripartite({
                        id: params.row.id
                    })
                    .then(res => {
                        if (res.result == 2) {
                            this.$message({ message: res.msg, type: "error" });
                        } else {
                            this.$message({
                                message: res.msg,
                                type: "success"
                            });
                            this.findPage(null);
                        }
                    });
            });
        },

        // 解锁锁定
        changeSwitch: function(data) {
            this.$api.school
                .schoolInfoLock({
                    schoolId: data.row.id,
                    isLock: data.row.isLock
                })
                .then(res => {
                    if (res.result == 1) {
                        this.$message({ message: res.msg, type: "success" });

                        //执行查询接口，刷新列表信息
                        this.queryBox.queryInterface = 4;
                        this.queryBox.pageNum = this.pageRequest.pageNum;
                        this.queryBox.pageSize = this.pageRequest.pageSize;
                        this.$api.school
                            .cusomerschoolList(this.queryBox)
                            .then(res => {
                                this.pageResult.content = res.listSchoolInfo;
                            })
                            .then(data != null ? data.callback : "");
                    } else {
                        this.$message({ message: res.msg, type: "error" });
                    }
                });
        },

        // 批量导入
        customerManagerImport: function() {
            this.uploadOem = true;
            if (this.form.file != "") {
                this.$refs.uploadExcel.clearFiles();
                this.form.file = "";
            }
        },
        // 文件超出个数限制时的钩子
        exceedFile(files, fileList) {
            this.$notify.warning({
                title: "警告",
                message: `只能选择 ${
                    this.limitNum
                } 个文件，当前共选择了 ${files.length + fileList.length} 个`
            });
        },
        // 文件状态改变时的钩子
        fileChange(file, fileList) {
            this.form.file = file.raw;
        },
        // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
        beforeUploadFile(file) {
            let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
            let size = file.size / 1024 / 1024;
            if ((extension !== "xlsx") & "xls") {
                this.$notify.warning({
                    title: "警告",
                    message: `只能上传Excel97-2004（即后缀是.xls）的文件`
                });
            }
        },
        // 文件上传成功时的钩子
        handleSuccess(res, file, fileList) {
            this.$refs.uploadExcel.clearFiles();
            this.form.file = "";
            this.$notify.success({
                title: "成功",
                message: `文件上传成功,数据处理中,稍后在我的消息中查看！`
            });
        },
        // 文件上传失败时的钩子
        handleError(err, file, fileList) {
            this.$notify.error({
                title: "错误",
                message: `文件上传失败`
            });
        },
        uploadFile() {
            let formData = new FormData();
            formData.append("file", this.form.file);
            axios
                .post(this.uploadUrl, formData, {
                    "Content-Type": "multipart/form-data"
                })
                .then(res => {
                    if (res.data.result == 1) {
                        let path = res.data.fileUrl;
                        this.$api.school
                            .myCustomerImport({ path: path })
                            .then(res => {
                                if (res.result == 2) {
                                    this.$message({
                                        message: res.msg,
                                        type: "error"
                                    });
                                    this.handleError();
                                } else {
                                    this.$message({
                                        message: res.msg,
                                        type: "success"
                                    });
                                    this.handleSuccess();
                                }
                                this.uploadOem = false;
                                this.findPage(null);
                            });
                    } else {
                        this.handleError();
                    }
                });
        },

        // 删除上传列表操作
        handleRemove(file, fileList) {
            this.form.file = "";
        },

        // 下载模板
        downloadTmpl() {
            this.getSchoolTempl();
        },

        // 获取部门数据
        get_dept_data() {
            this.$api.dropdown.deptLevel3().then(res => {
                this.deptData = res.departmentInfoList;
            });
        },

        //划分方式 控制部门人员显示
        deptmodeoptionsChange(value) {
            if (value == 9) {
                this.isShowFlag = 2;
                this.AllotData.belong_to_type = 1; //个人
                this.AllotData.thirdLevelDepartment = 0; //清空
            } else if (value == 11) {
                this.isShowFlag = 1;
                this.AllotData.belong_to_type = 2; //部门
                this.AllotData.userId = 0;
            } else {
                this.isShowFlag = 0;
            }
        },

        // 点击部门
        handleTreeSelectChange3Add(data, node) {
            this.deptinputValue = data.deptName;
            this.AllotData.thirdLevelDepartment = data.id;
            this.AllotData.userId = data.id;
            this.AllotData.userId = "";
            this.get_dept_user();
        },

        // 获取部门用户
        get_dept_user() {
            this.$api.student
                .queryUserList({
                    get_dept_user: this.AllotData.thirdLevelDepartment
                })
                .then(res => {
                    this.deptuseroption = res.userInfoList;
                });
        },

        // 查看客户档案
        handleSee: function(params) {
            this.$router.push({
                path: "/Customerfile/ThreeFileBase",
                query: {
                    id: params.row.id
                }
            });
        },

        // 修改客户档案
        handleEdit: function(params) {
            this.dataForm = Object.assign({}, params.row);
            this.$router.push({
                path: "/Customerfile/ThreeFile",
                query: {
                    id: this.dataForm.id,
                    recordInfoId: params.row.recordInfoId,
                    auditStatus: params.row.auditStatus
                }
            });
        },

        // 获取选中的表格数据
        selectionChange: function(params) {
            let selectionsLength = params.selections.length;
            this.selections = params.selections;
            this.ids = [];
            let idstu = this.selections.map(item => item.id);
            this.ids = idstu;
        },

        // 新增客户
        handleNewADD: function() {
            this.$router.push({
                path: "/Customerfile/ThreeFile"
            });
        },
        // 获取地区
        handleChange(value) {
            this.schoolInfo.city = value;
        },
        // 获取时间
        dateFormat: function(time) {
            var date = new Date(time);
            var year = date.getFullYear();
            /* 在日期格式中，月份是从0开始的，因此要加0
             * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
             * */
            var month =
                date.getMonth() + 1 < 10
                    ? "0" + (date.getMonth() + 1)
                    : date.getMonth() + 1;
            var day =
                date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var hours =
                date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
            var minutes =
                date.getMinutes() < 10
                    ? "0" + date.getMinutes()
                    : date.getMinutes();
            var seconds =
                date.getSeconds() < 10
                    ? "0" + date.getSeconds()
                    : date.getSeconds();
            // 拼接
            return (
                year +
                "-" +
                month +
                "-" +
                day +
                " " +
                hours +
                ":" +
                minutes +
                ":" +
                seconds
            );
        },
        handleReport(params) {
            this.reportShow = true;
            this.recordData.name = params.row.name;
            this.recordData.tripartiteId = params.row.id;
            this.findPage3(null);
        },
        // 保存跟进
        handleSaveRecord() {
            this.$api.school.saveTrackingInfo(this.recordData).then(res => {
                if (res.result == 2) {
                    this.$message({ message: res.msg, type: "error" });
                } else {
                    this.$message({ message: res.msg, type: "success" });
                    this.reportShow = false;
                    this.recordData.name = "";
                    this.recordData.tripartiteId = "";
                    this.recordData = {};
                }
            });
        },
        // 查询跟进列表
        findPage3(data) {
            if (data !== null) {
                this.pageRequest3 = data.pageRequest;
            }

            this.$api.school
                .sfTrackingInfoPageList({
                    tripartiteId: this.recordData.tripartiteId,
                    pageSize: this.pageRequest3.pageSize,
                    pageNum: this.pageRequest3.pageNum
                })
                .then(res => {
                    let content = {
                        content: res.data,
                        totalSize: res.total
                    };
                    this.detailRecordInfoData = content;
                    this.detailRecordInfoData.content.forEach(item => {
                        this.school_recordType_options.forEach(type_item => {
                            if (type_item.key == item.recordType) {
                                item.recordType = type_item.value;
                            }
                        });
                        item.communicationDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.communicationDate
                        );
                        item.nextTrackingDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.nextTrackingDate
                        );
                    });
                })
                .then(data != null ? data.callback : "");
        },
         // 导出
        handleExport(){
            axios({
                method: "get",
                url: baseUrl + "/schoolTripartite/exportTripartiteData",
                params: this.queryBox
            }).then(res => {
                window.open(res.request.responseURL);
            });
        }
    },
    mounted() {
        this.transformRouteBtnParam()
        this.get_student_type();
        this.get_student_data_from();
        this.get_student_data_from_type();
        this.get_student_progress();
        this.get_level_cache();
        this.get_dataTime();
    }
};
</script>
<style>
@import url("../../assets/queryBox.css");
</style>
<style lang="scss" scope>
.MyThreePop {
    .el-row .el-col {
        margin-left: 0;
    }
}
.add-btns .el-button:nth-child(1) {
    margin-right: 10px;
}
.second-contain-box {
    width: 95%;
    margin: 0 auto;
    .el-col {
        text-align: left;
        margin: 4px 0;
    }
    .el-row {
        margin: 0 0 !important;
    }
    .el-col i {
        font-style: normal;
        display: inline-block;
    }
}
.second-contain-box2 {
    .el-col i {
        margin-top: 0px !important;
    }
}
.schoolBoxCont {
    margin: 5px 5px;

    .schoolBoxContItem {
        margin-right: 10px;
        float: left;
        .el-form-item__content {
            display: flex;
            flex-direction: row;
        }
        .schoolBoxContItemTitle {
            background: #f5f7fa;
            width: 115px;
            border: 1px solid #dcdfe6;
            border-top-left-radius: 4px;
            border-bottom-left-radius: 4px;
            line-height: 39px;
            border-right: none;
        }
        .schoolBoxContItemInput {
            width: 150px;
            line-height: 39px;
            .el-date-editor.el-input,
            .el-date-editor.el-input__inner {
                width: 100%;
            }
        }
    }
}
</style>
